﻿<xsl:stylesheet version="1.0"
  xmlns:date="http://exslt.org/dates-and-times"
  xmlns:set="http://exslt.org/sets"  
  xmlns:ms="urn:schemas-microsoft-com:xslt"
  xmlns:dt="urn:schemas-microsoft-com:datatypes"
  xmlns:ebe="http://cks/ebemethods"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  exclude-result-prefixes="date set ebe">

	<xsl:param name="IsBlogOwner" />
	<xsl:param name="RelativeUrl" />
  <xsl:param name="Language" />

	<xsl:output omit-xml-declaration="yes" />
	<xsl:key match="rows/row" use="substring(PublishedDate, 0, 8)" name="months" />

	<xsl:template match="/">

    <xsl:apply-templates select="rows/row[generate-id(.) = generate-id(key('months', substring(PublishedDate, 0, 8)))]">
      <xsl:sort select="PublishedDate" order="descending" />
    </xsl:apply-templates>

	</xsl:template>

	<xsl:template match="row">

		<xsl:variable name="publishedDate" select="date:parseDate(PublishedDate, 'yyyy-MM-dd HH:mm:ss')"/>
		<xsl:variable name="postCount" select="count(key('months',substring(PublishedDate, 0, 8)))"/>

		<a title="{Title}">
			<xsl:attribute name="href">
				<xsl:value-of select="ebe:createMonthUrl(PublishedDate)"/>
			</xsl:attribute>
			<xsl:value-of select="ms:format-date($publishedDate, 'MMMM yyyy', $Language)"/> (<xsl:value-of select="$postCount"/>)
		</a><br/>
	</xsl:template>

</xsl:stylesheet>
